/*
 * Copyright 2016 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.kie.workbench.common.screens.datamodeller.client.widgets.editor;

import java.util.List;

import com.google.gwt.view.client.ListDataProvider;
import org.guvnor.common.services.shared.validation.model.ValidationMessage;
import org.gwtbootstrap3.client.ui.constants.ButtonType;
import org.kie.workbench.common.services.datamodeller.core.DataObject;
import org.kie.workbench.common.services.datamodeller.core.ObjectProperty;
import org.uberfire.backend.vfs.Path;
import org.uberfire.client.mvp.UberView;
import org.uberfire.ext.widgets.common.client.common.HasBusyIndicator;
import org.uberfire.mvp.Command;

public interface DataObjectBrowserView
        extends UberView<DataObjectBrowserView.Presenter>,
                HasBusyIndicator {

    interface Presenter {

        void onSelectCurrentDataObject();

        void onSelectPropertyType(ObjectProperty property);

        void onDeleteProperty(final ObjectProperty objectProperty,
                              final int index);

        void onSelectProperty(ObjectProperty selectedProperty);

        void onNewProperty();

        void onSortByName(boolean ascending);

        void onSortByLabel(boolean ascending);

        void onSortByType(boolean ascending);

        String getPropertyTypeDisplayValue(ObjectProperty property);

        boolean isSelectablePropertyType(ObjectProperty property);

        DataObject getDataObject();
    }

    void setDataProvider(ListDataProvider<ObjectProperty> dataProvider);

    ObjectProperty getSelectedRow();

    void setSelectedRow(ObjectProperty objectProperty,
                        boolean select);

    void redrawRow(int row);

    void redrawTable();

    void setReadonly(boolean readonly);

    void enableNewPropertyAction(boolean enable);

    void enableDeleteRowAction(boolean enable);

    void setObjectSelectorLabel(String label,
                                String title);

    void setTableHeight(int height);

    int getTableHeight();

    void showYesNoCancelPopup(final String title,
                              final String content,
                              final Command yesCommand,
                              final String yesButtonText,
                              final ButtonType yesButtonType,
                              final Command noCommand,
                              final String noButtonText,
                              final ButtonType noButtonType,
                              final Command cancelCommand,
                              final String cancelButtonText,
                              final ButtonType cancelButtonType);

    void showValidationPopupForDeletion(final List<ValidationMessage> validationMessages,
                                        final Command yesCommand,
                                        final Command cancelCommand);
}
